package ch.headshot.photomap.client.editor.view;

import ch.headshot.photomap.client.editor.control.ConcatCommand;
import ch.headshot.photomap.client.editor.control.LoadGpxCommand;
import ch.headshot.photomap.client.editor.control.SaveGpxCommand;
import ch.headshot.photomap.client.editor.control.ShowGpxCommand;
import ch.headshot.photomap.client.editor.control.SimplifyCommand;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;

public class Menu extends MenuBar {

	public Menu() {
		super(false);
		addItem("GPX", getGpxMenu());
		addItem("Track", getTrackMenu());
		addItem("Route", getRouteMenu());
		addItem("WayPoint", getWayPointMenu());
		addItem("Help", getHelpMenu());

	}

	private MenuBar getTrackMenu() {
		MenuBar trackMenu = new MenuBar(true);
		trackMenu.addItem(new MenuItem("simplify", new SimplifyCommand()));
		trackMenu.addItem(new MenuItem("concat", new ConcatCommand()));
		return trackMenu;
	}

	private MenuBar getGpxMenu() {
		MenuBar gpxBar = new MenuBar(true);
		gpxBar.addItem("Load", new LoadGpxCommand());
		gpxBar.addItem("Save", new SaveGpxCommand());
		gpxBar.addItem("Show", new ShowGpxCommand());
		return gpxBar;
	}

	private MenuBar getRouteMenu() {
		MenuBar gpxBar = new MenuBar(true);
		gpxBar.addItem(notYetImplemented());
		return gpxBar;
	}

	private MenuBar getWayPointMenu() {
		MenuBar gpxBar = new MenuBar(true);
		gpxBar.addItem(notYetImplemented());
		return gpxBar;
	}

	private MenuBar getHelpMenu() {
		MenuBar gpxBar = new MenuBar(true);
		gpxBar.addItem(notYetImplemented());
		return gpxBar;
	}

	private MenuItem notYetImplemented() {
		MenuItem nyi = new MenuItem("notYetImplemented", new Command() {

			public void execute() {
				Window.alert("not yet implemented");
			}
		});
		return nyi;
	}
}
